package com.farm.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.farm.dao.InsertDao;
import com.farm.service.InsertService;
import com.farm.utils_all.HUtil;
import com.farm.utils_all.XVDateUtils;

@Service("InsertService")
public class InsertServiceimpl implements InsertService {
	
	@Autowired
	private InsertDao insertDao;
	
	//签到插入,查询签到人员信息和会议信息
	@Override
	public Map<String, Object> insert(Map<String, Object> map) {
		//查询当前用户信息
		Map<String, Object> selectInsert = insertDao.selectInsert(map);
		System.out.println(selectInsert);
	    int currenTimeMillis = XVDateUtils.getCurrenTimeMillis();
	    
	    //修改签到信息和OPENID
	    map.put("u_qd",1);
	    insertDao.insertOpenid(map);
	    
	    //int b=Integer.valueOf(selectInsert.get("u_qd").toString());
	    
	    //查询此人签到表信息
	    List<Map<String, Object>> selectff = insertDao.selectff(map);
	    if(selectff.size() == 0) {
	    	int insert = insertDao.insert(HUtil.putInMap("u_id",selectInsert.get("u_id"),"f_id",selectInsert.get("f_id"),"sign_in_time",currenTimeMillis,"u_name",selectInsert.get("u_name")));
	    	return HUtil.putInMap("id",insert);
	    }else {
	    	return HUtil.putInMap("code",400,"msg","已签到");
	    }
		
		
		
	}
	
	
	

}
